<extend name="Common:common" />
<block name="cssjs"></block>
<block name="body">
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <a href="__MODULE__/Index/info">首页</a> &raquo; <a href="__URL__/index">招聘管理</a>
    </div>
    <!--面包屑导航 结束-->

    <!--搜索结果页面 列表 开始-->
    <form action="#" method="post">
        <div class="result_wrap">
            <!--快捷导航 开始-->
            <div class="result_content">
                <div class="short_wrap">
                    <a href="__URL__/add" class="linkblue">添加职位</a>
                    <a href="javascript:;" onclick="dels();" class="linkblue">批量删除</a>
                    <a href="__URL__/index" class="linkblue">刷新</a>
                </div>
            </div>
            <!--快捷导航 结束-->
        </div>

        <div class="result_wrap">
            <div class="result_content">
                <table class="list_tab">
                    <tr>
                        <th width="4%"><input type="checkbox" name=""></th>
                        <th width="4%"><strong>ID</strong></th>
                        <th width="4%"><strong>排序</strong></th>
                        <th width="25%"><strong>职位名称</strong></th>
                        <th width="25%"><strong>工作地点</strong></th>
                        <th width="25%"><strong>招聘人数</strong></th>
                        <th><strong>操作</strong></th>
                    </tr>
                    <foreach name="list" item="v">
                            <tr>
                                <td><input type="checkbox" name="id[]" value="{$v['job_id']}"></td>
                                <td>{$v['job_id']}</td>
                                <td>
                                    <input type="text" name="job_sort" value="{$v['job_sort']}" onchange="sort(this, {$v['job_id']})">
                                </td>
                                <td>
                                   {$v['job_name']}
                                </td>
                                <td>
                                   {$v['job_where']}
                                </td>
                                <td>
                                   {$v['job_num']}
                                </td>
                                <td>
                                    <a href="__URL__/edit/job_id/{$v['job_id']}">编辑</a> <a>|</a>
                                    <a href="javascript:;" onclick="del({$v['job_id']});">删除</a> <a>|</a>
                                    <if condition="$v['job_status'] eq 0">
                                        <a href="javascript:;" onclick="start({$v['job_id']}, 0)">已开启</a>
                                    <else />  
                                        <a href="javascript:;" onclick="start({$v['job_id']}, 1)">已关闭</a>                                 
                                    </if>
                                </td>
                            </tr>
                    </foreach>
                    
                </table>

            </div>
        </div>
    </form>
    <!--搜索结果页面 列表 结束-->

</body>
<script>
    //删除
    function del(id) {
        dialog.confirm('确定删除吗?', '__URL__/del', '__URL__/index', id);
    }

    //批量删除
    function dels() {
        var id = '';
        var ids = $('.list_tab').find('tr').find('td').find('input:checked');
        var num = ids.length;
        for(var i = 0; i < num; i++) {
            id += ids[i].value + ',';
        }
        id = id.substring(0, id.length-1);
        if(id == '') {
            dialog.error('请至少选择一项!');
        } else {
            dialog.confirm('确定删除吗?', '__URL__/dels', '__URL__/index', id);
        }
    }

    //开启 or 停止
    function start(job_id, status) {
        if(status == 0) {
            var msg = '确定要关闭该职位的招聘吗?';
        } else {
            var msg = '确定要开启该职位的招聘吗?';
        }
        dialog.confirm(msg, '__URL__/status', '__URL__/index', job_id);
    }

    //更改排序
    function sort(obj, job_id) {
        var job_sort = $(obj).val();
        $.ajax({
            type        : 'POST',
            url         : '__URL__/sort',
            data        : {job_sort : job_sort, job_id : job_id},
            success     : function(info) {
                if(info.code == '201') {
                    dialog.error(info.msg);
                } else {
                    dialog.success(info.msg, '__URL__/index');
                }
            }
        });
    }

</script>
</block>